package com.zjjxy.controller.student;
import com.zjjxy.pojo.dto.StudentAnswerDTO;
import com.zjjxy.pojo.entity.Question;
import com.zjjxy.pojo.entity.StudentAnswer;
import com.zjjxy.pojo.vo.StudentLoginVO;
import com.zjjxy.result.Result;
import com.zjjxy.service.impl.TeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
public class TeacherPublishController {
    @Autowired
    private TeacherService teacherService;

    /**
     * 发布题目
     * @param id
     * @return
     */
    @PostMapping("/teacher/publish/start/{id}")
    public Result publish(@PathVariable Integer id) {
        log.info("发布题目：{}");
        teacherService.publish(id);
        return Result.success();
    }

    @PutMapping("/teacher/publish/stop/{id}")
    public Result stop(@PathVariable Integer id) {
        log.info("停止发布题目：{}");
        teacherService.stop(id);
        return Result.success();
    }

    @PutMapping("/common/question")
    public Result post(@RequestBody StudentAnswerDTO studentAnswerDTO){
        log.info("新增学生答案：{}",studentAnswerDTO);
        teacherService.post(studentAnswerDTO);
        return  Result.success();
    }

    @GetMapping("/common/rank")
    public List<StudentAnswer> getScore(){
        return teacherService.getScore();
    }

    @GetMapping("/teacher/question")
    public List<Question> randow(){
        return teacherService.ranDow();
    }
}
